#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c=28;
    scanf("%d %d",&a,&b);
    if(b==2)
    {
        if(a%4==0&&a%100!=0||a%400==0)
        {
            c=29;
        }
    }
    switch(b)
    {
        case 1:printf("%d",31);break;
        case 2:printf("%d",c);break;
        case 3:printf("%d",31);break;
        case 4:printf("%d",30);break;
        case 5:printf("%d",31);break;
        case 6:printf("%d",30);break;
        case 7:printf("%d",31);break;
        case 8:printf("%d",31);break;
        case 9:printf("%d",30);break;
        case 10:printf("%d",31);break;
        case 11:printf("%d",30);break;
        case 12:printf("%d",31);break;
    }
    return 0;
}
